From 55ae8e1103f4697bfa01a84301a6560b89de5248 Mon Sep 17 00:00:00 2001
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
Date: Mon, 16 Apr 2018 19:52:34 +0300
Subject: [PATCH] configure: add option to disable tests

When building for a product, tests are not needed.

Besides, one test requires a C++ compiler, which is not always
available.

So, add an option to configure to disable building tests altogether.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Tested-by: Eric Engestrom <eric.engestrom@imgtec.com>

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>

---
Changes v1 -> v2:
  - fix typo in yes-check  (Eric)
---
 Makefile.am  | 2 ++
 configure.ac | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 741db5ebf9d9..4862d42959f0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -160,6 +160,7 @@ pkgconfig_DATA += egl/wayland-egl.pc
 include_HEADERS += egl/wayland-egl-backend.h
 pkgconfig_DATA += egl/wayland-egl-backend.pc
 
+if ENABLE_TESTS
 built_test_programs =				\
 	array-test				\
 	client-test				\
@@ -287,6 +288,7 @@ os_wrappers_test_LDADD = libtest-runner.la
 
 exec_fd_leak_checker_SOURCES = tests/exec-fd-leak-checker.c
 exec_fd_leak_checker_LDADD = libtest-runner.la
+endif
 
 EXTRA_DIST += tests/scanner-test.sh			\
 	protocol/tests.xml				\
diff --git a/configure.ac b/configure.ac
index c74ee97b24a2..5c94b7b76b06 100644
--- a/configure.ac
+++ b/configure.ac
@@ -89,10 +89,18 @@ AC_ARG_ENABLE([dtd-validation],
 	      [],
 	      [enable_dtd_validation=yes])
 
+AC_ARG_ENABLE([tests],
+	      [AC_HELP_STRING([--disable-tests],
+			      [Disable compilation of test programs])],
+	      [],
+	      [enable_tests=yes])
+
 AM_CONDITIONAL(USE_HOST_SCANNER, test "x$with_host_scanner" = xyes)
 
 AM_CONDITIONAL(ENABLE_LIBRARIES, test "x$enable_libraries" = xyes)
 
+AM_CONDITIONAL(ENABLE_TESTS, test "x$enable_tests" = xyes)
+
 AC_ARG_WITH(icondir, [  --with-icondir=<dir>    Look for cursor icons here],
 		     [  ICONDIR=$withval],
 		     [  ICONDIR=${datadir}/icons])
-- 
2.14.3

